/*
 * @Author: szx
 * @Date: 2021-11-08 12:41:59
 * @LastEditTime: 2021-11-08 12:53:11
 * @Description:
 * @FilePath: \leetcode\200-299\299\299.cpp
 */
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;

class Solution {
   public:
    string getHint(string secret, string guess) {
        int bulls = 0, cows = 0;
        unordered_map<int, int> m;
        int n = secret.length();
        for (int i = 0; i < n; i++) {
            if (secret[i] == guess[i]) {
                bulls++;
                guess[i] = 'a';
            } else {
                m[secret[i]]++;
            }
        }
        for (int i = 0; i < n; i++) {
            if (guess[i] != 'a' && m[guess[i]] > 0) {
                cows++;
                m[guess[i]]--;
            }
        }
        return to_string(bulls) + 'A' + to_string(cows) + 'B';
    }
};
int main() { return 0; }